import { http } from "@/utils/http";
// 转换字符串，undefined,null等转化为""
export function parseStrEmpty(str) {
  if (!str || str == "undefined" || str == "null") {
    return "";
  }
  return str;
}
// 查询字典类型列表
export function listType(query) {
  return http.request("get", "/system/dict/type/list", { params: query });
}

// 查询字典类型详细
export function getType(dictId) {
  return http.request("get", "/system/dict/type/" + parseStrEmpty(dictId));
}

// 新增字典类型
export function addType(data) {
  return http.request("post", "/system/dict/type", { data });
}

// 修改字典类型
export function updateType(data) {
  return http.request("put", "/system/dict/type", { data });
}

// 删除字典类型
export function delType(dictId) {
  return http.request("delete", "/system/dict/type/" + dictId);
}

// 刷新字典缓存
export function refreshCache() {
  return http.request("delete", "/system/dict/type/refreshCache");
}

// 获取字典选择框列表
export function optionselect() {
  return http.request("get", "/system/dict/type/optionselect");
}
